using System;
using System.Data.Common;
using Dm;
using JetBrains.Annotations;
using Microsoft.EntityFrameworkCore.Dm.Infrastructure.Internal;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage;

namespace Microsoft.EntityFrameworkCore.Dm.Storage.Internal;

public class DmRelationalConnection : RelationalConnection, IDmRelationalConnection, IRelationalConnection, IRelationalTransactionManager, IDbContextTransactionManager, IResettableService, IDisposable, IAsyncDisposable
{
	public const string EFPDBAdminUser = "SYSDBA";

	internal const int DefaultMasterConnectionCommandTimeout = 60;

	protected override bool SupportsAmbientTransactions => true;

	public DmRelationalConnection([NotNull] RelationalConnectionDependencies dependencies)
		: base(dependencies)
	{
	}

	protected override DbConnection CreateDbConnection()
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_000d: Expected O, but got Unknown
		return (DbConnection)new DmConnection(((RelationalConnection)this).ConnectionString, true);
	}

	public virtual IDmRelationalConnection CreateMasterConnection()
	{
		
		DmConnectionStringBuilder val = new DmConnectionStringBuilder(((RelationalConnection)this).ConnectionString)
		{
			User = "SYSDBA",
			Password = "SYSDBA",
			Schema = ""
		};
		DbContextOptions options = DmDbContextOptionsExtensions.UseDm(new DbContextOptionsBuilder(), val.ConnectionString, delegate(DmDbContextOptionsBuilder b)
		{
			b.CommandTimeout(this.CommandTimeout.GetValueOrDefault(60));
		}).Options;
		RelationalConnectionDependencies obj = this.Dependencies;		
		return new DmRelationalConnection(obj);
	}
}
